<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>企业信息</title>
	<link rel="stylesheet" href="/css/style.css">
	<script src="/js/jquery-2.1.4.min.js"></script>
	<link href="/css/main.css" rel="stylesheet">
	<script src="/js/laydate.js"></script>
	<link rel="stylesheet" type="text/css" href="/css/jquery.my-modal.1.1.winStyle.css" />
	<script type="text/javascript" src="/js/jquery.my-modal.1.1.js"></script>





	<style>
		.title span:nth-child(1)
	</style>
	<style type="text/css">
		#weiguineir,.chuna,#chrye{
		}
		.prd{
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}
		.push_button{
			background: #ededed;
			background-image: -webkit-linear-gradient(top, #ededed, #bab1ba);
			background-image: -moz-linear-gradient(top, #ededed, #bab1ba);
			background-image: -ms-linear-gradient(top, #ededed, #bab1ba);
			background-image: -o-linear-gradient(top, #ededed, #bab1ba);
			background-image: linear-gradient(to bottom, #ededed, #bab1ba);
			-webkit-border-radius: 15;
			-moz-border-radius: 15;
			border-radius: 15px;
			text-shadow: 0px 1px 0px #e1e2ed;
			-webkit-box-shadow: 3px 4px 0px 0px #899599;
			-moz-box-shadow: 3px 4px 0px 0px #899599;
			box-shadow: 3px 4px 0px 0px #899599;
			font-family: Arial;
			color: #3a8a9e;
			font-size: 16px;
			padding: 12px 30px 12px 30px;
			border: solid #d6bcd6 1px;
			text-decoration: none;
			margin: 15px;
		}
		.heading{
			margin: 5px;
		}
		.push_button:hover {
			color: #3a8a9e;
			background: #bab1ba;
			text-decoration: none;
		}
		.ha{
			width:100%;
		}
	</style>
</head>
<body style="background: #F2F2F2;">

<form class="serachr" action="/ninesmall/search" method="post">
	{{ csrf_field() }}
	<input type="hidden" name="categoryId" value="{{$categoryId}}">
	<input class="text" type="text" name="name" placeholder="请输入企业名称进行搜索">
	<input class="sub" type="submit" value="搜  索" name="">
	<div style="clear: both;"></div>
</form>


<form action="/ninesmall/create" method="post" enctype="multipart/form-data">
	{{ csrf_field() }}
	<input type="hidden" name="company[categoryId]" value="{{$categoryId}}">
	<input type="hidden" name="id" value="{{$company->id or ''}}">
	<div class="bx zitidaxiao">
		<ul class="ybzl yuae">

			<li><p>企业名称 <span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->comName or ''}}" name="company[comName]" placeholder="请填写企业名称" /></li>

			<li class="qiyedizhix"><p>企业地址 <span style="color: red;display: block;">(必填项)</span></p>

				<!--<input id="cruanas" value="" class="form-control" readonly type="text" data-toggle="city-picker" placeholder="点击从下拉面板中选择省-市-县-街道">-->
				<select name="company[province]" class="province">
					<option value="0">省</option>
					@foreach($provinces as $province)
						<option value="{{$province->id}}" @if(!isset($company->province) && $province->id==370000) selected @endif  @if(isset($company->province) && $company->province == $province->id) selected @endif >{{$province->name}}</option>
					@endforeach
				</select>
				<select name="company[city]" class="city">
					@if(isset($company->city))
						<option value="0">市</option>
						<option value="{{$company->city}}" selected >{{$city}}</option>
					@else
						@foreach($city as $ci)
							<option value="{{$ci->id}}" @if($ci->id==370200) selected @endif>{{$ci->name}}</option>
						@endforeach
					@endif

				</select>
				<select name="company[district]" class="area">
					@if(isset($company->district))
						<option value="0">区</option>
						<option value="{{$company->district}}" selected >{{$district}}</option>
					@else
						<option value="0">区</option>
						@foreach($district as $di)
							<option value="{{$di->id}}">{{$di->name}}</option>
						@endforeach
					@endif
				</select>
				<select name="company[street]" class="street">
					@if(isset($company->street))
						<option value="0">街道</option>
						<option value="{{$company->street}}" selected >{{$street}}</option>
					@else
						<option value="0">街道</option>
					@endif
				</select>
				<input type="hidden" value="" id="area" name="area"></li>
			<li><p></p><input type="text" value="{{$company->address or '' }}" name="company[address]"  placeholder="请输入街道、门牌号等信息" /></li>
			<li><p>邮政编码</p><input type="number" value="{{$company->postcode or '' }}" name="company[postcode]" placeholder="请填写邮政编码" /></li>
			<li><p>法定代表人姓名<span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->leader or '' }}" name="company[leader]" placeholder="请填写法人姓名" /></li>
			<li><p>法定代表人电话</p><input type="number" value="{{$company->leaderPhone or '' }}" name="company[leaderPhone]" placeholder="请填写法人电话" /></li>
			<li><p>建筑面积<span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->area or '' }}" name="company[area]" placeholder="请填写建筑面积" /></li>
			<li><p>技术服务机构人员</p><input type="text" value="{{$company->service or '' }}" name="company[service]" placeholder="请填写技术服务机构人员" /></li>
			<li><p>企业陪同人员<span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->accompany or '' }}" name="company[accompany]" placeholder="请填写陪同人员" /></li>
			<li><p>员工人数<span style="color: red;display: block;">(必填项)</span></p><input type="number" value="{{$company->workersNum or '' }}" name="company[workersNum]" placeholder="请填写员工人数" /></li>
		<!--<li><p>主要原料<span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->material or '' }}" name="company[material]" placeholder="请填写主要原料" /></li>
			<li><p>主要产品<span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->product or '' }}" name="company[product]" placeholder="请填写主要产品" /></li>
			<li><p>固定资产<span style="color: red;display: block;">(必填项)</span></p><input type="text" value="{{$company->assets or '' }}" name="company[assets]" placeholder="请填写固定资产" /></li>
			<li><p>年收入</p><input type="number" min="0" step="0.01" value="{{$company->income or '' }}" name="company[income]" placeholder="请填写年收入" /></li>-->
			<li><p>占地面积<span style="color: red;display: block;">(必填项)</span></p><input type="number" value="{{$company->space or '' }}" name="company[space]" placeholder="请填写面积" /></li>
			<div id="safe">
				<li><p>安全管理人员姓名 <span style="color: red;">(必填项)</span></p><input type="text" value="{{$safeoffer[0]->name or '' }}" name="safe[name][]" placeholder="请填写安全管理人员姓名" /></li>
				<li><p>安全管理人员电话 <span style="color: red;">(必填项)</span></p><input type="text" value="{{$safeoffer[0]->phone or '' }}" name="safe[phone][]" placeholder="请填写安全管理人员电话" /></li>
				@if(!empty($safeoffer))
					@foreach($safeoffer as $k=>$sa)
						<ul>
							@if($k !== 0)
								<li><p>安全管理人员姓名</p><input type="text" value="{{$sa->name or ''}}" name="safe[name][]" placeholder="请填写安全管理人员姓名" /></li>
								<li><p>安全管理人员电话</p><input type="text" value="{{$sa->phone or ''}}" name="safe[phone][]" placeholder="请填写安全管理人员电话" /></li>
								<div class="del" style="left: 10px;width: 30px;height: 30px;margin-top:30px" onclick="del(this)"></div>
						</ul>
						@endif
					@endforeach
				@endif

			</div>
			<input type="button" style="display:block;width: 200px;padding: 10px 0;background: #33AAFF;color: #FFF;border: 0;font-size: 14px;border-radius:3px;margin: 10px auto" class="safe" value="添加安全管理人员" onclick="safe()"/>
			<script>
				var safeLen = 1;
				function safe(){
					var bo = document.getElementById('safe');//获取div对象.
					//设置数组键值
					var setLength = safeLen;
					safeLen = safeLen+1;
					//创建一个ul
					var ul = document.createElement('ul');
					//设置div的属性
					ul.innerHTML = '<li><p>安全管理人员姓名</p><input type="text" value="" name="safe[name][]" placeholder="请填写安全管理人员姓名" /></li><li><p>安全管理人员电话</p><input type="text" value="" name="safe[phone][]" placeholder="请填写安全管理人员电话" /></li><div class="del" style="left: 10px;width: 30px;height: 30px;margin-top:30px" onclick="del(this)"></div>'; //设置显示的数据
					//动态插入
					bo.insertBefore(ul,bo.lastChild);
				}
			</script>
			<div id="main">
				<li><p>主要负责人员姓名 <span style="color: red;">(必填项)</span></p><input type="text" value="{{$manager[0]->name or '' }}" name="manger[name][]" placeholder="请填写主要负责人员姓名" /></li>
				<li><p>主要负责人员电话 <span style="color: red;">(必填项)</span></p><input type="text" value="{{$manager[0]->phone or '' }}" name="manger[phone][]" placeholder="请填写主要负责人员电话" /></li>
				<li><p>主要负责人员微信 <span style="color: red;">(必填项)</span></p><input type="text" value="{{$manager[0]->wx or '' }}" name="manger[wx][]" placeholder="请填写主要负责人员微信" /></li>
				@if(!empty($safeoffer))

					@foreach($manager as $k=>$ma)
						<ul>
							@if($k !== 0)
								<li><p>主要负责人员姓名</p><input type="text" value="{{$ma->name or ''}}" name="manger[name][]" placeholder="请填写主要负责人员姓名" /></li>
								<li><p>主要负责人员电话</p><input type="text" value="{{$ma->phone or ''}}" name="manger[phone][]" placeholder="请填写主要负责人员电话" /></li>
								<li><p>主要负责人员微信</p><input type="text" value="{{$ma->wx or ''}}" name="manger[wx][]" placeholder="请填写主要负责人员微信" /></li>
								<div class="del" style="left: 10px;width: 30px;height: 30px;margin-top:30px" onclick="del(this)"></div>
						</ul>
						@endif
					@endforeach
				@endif

			</div>
			<input type="button" style="display:block;width: 200px;padding: 10px 0;background: #33AAFF;color: #FFF;border: 0;font-size: 14px;border-radius:3px;margin: 10px auto" class="safe" value="添加主要负责人" onclick="main()"/>
			<script>
				var safeLen = 1;
				function main(){
					var bo = document.getElementById('main');//获取div对象.
					//设置数组键值
					var setLength = safeLen;
					safeLen = safeLen+1;
					//创建一个ul
					var ul = document.createElement('ul');
					//设置div的属性
					ul.innerHTML = '<li><p>主要负责人员姓名</p><input type="text" value="" name="manger[name][]" placeholder="请填写主要负责人员姓名" /></li><li><p>主要负责人员电话</p><input type="text" value="" name="manger[phone][]" placeholder="请填写主要负责人员电话" /></li><li><p>主要负责人员微信</p><input type="text" value="" name="manger[wx][]" placeholder="请填写主要负责人员微信" /></li><div class="del" style="left: 10px;width: 30px;height: 30px;margin-top:30px" onclick="del(this)"></div>'; //设置显示的数据
					//动态插入
					bo.insertBefore(ul,bo.lastChild);
				}
			</script>
		<!--h1 style="font-size: 16px">特种作业</h1>
			<li>
				<p>电工作业</p>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[electrician]" value="1" @if(isset($company) && $company->electrician == 1) checked @endif>
					<span class="demo--radioInput"></span>是
				</label>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[electrician]" value="2" @if(isset($company) && $company->electrician == 2) checked @elseif(!isset($company)) checked @endif>
					<span class="demo--radioInput"></span>否
				</label>
			</li>
			<li>
				<p>焊接与热切割作业</p>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[weld]" value="1" @if(isset($company) && $company->weld == 1) checked @endif>
					<span class="demo--radioInput"></span>是
				</label>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[weld]" value="2" @if(isset($company) && $company->weld == 2) checked @elseif(!isset($company)) checked @endif>
					<span class="demo--radioInput"></span>否
				</label>
			</li>
			<li>
				<p>高处作业</p>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[highwork]" value="1" @if(isset($company) && $company->highwork == 1) checked @endif>
					<span class="demo--radioInput"></span>是
				</label>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[highwork]" value="2" @if(isset($company) && $company->highwork == 2) checked @elseif(!isset($company)) checked @endif>
					<span class="demo--radioInput"></span>否
				</label>
			</li>
			<li>
				<p>制冷与空调</p>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[refrigeration]" value="1" @if(isset($company) && $company->refrigeration == 1) checked @endif>
					<span class="demo--radioInput"></span>是
				</label>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[refrigeration]" value="2" @if(isset($company) && $company->refrigeration == 2) checked @elseif(!isset($company)) checked @endif>
					<span class="demo--radioInput"></span>否
				</label>
			</li>-->
		<!--h1 style="font-size: 16px">特种设备</h1>
			<li><p>锅炉</p><input type="number" value="{{$company->boiler or '' }}" name="company[boiler]" placeholder="请填写数量" /></li>
			<li><p>空压机</p><input type="number" value="{{$company->kongyaji or '' }}" name="company[kongyaji]" placeholder="请填写数量" /></li>
			<li><p>气瓶</p><input type="number" value="{{$company->qiping or '' }}" name="company[qiping]" placeholder="请填写数量" /></li>
			<li><p>压力管道</p><input type="number" value="{{$company->ylgd or '' }}" name="company[ylgd]" placeholder="请填写数量" /></li>
			<li><p>电梯</p><input type="number" value="{{$company->elevator or '' }}" name="company[elevator]" placeholder="请填写数量" /></li>
			<li><p>起重机械</p><input type="number" value="{{$company->qzjx or '' }}" name="company[qzjx]" placeholder="请填写数量" /></li>
			<li><p>场(厂)内专用机动车辆</p><input type="number" value="{{$company->jdcl or '' }}" name="company[jdcl]" placeholder="请填写数量" /></li-->

			<h1 style="font-size: 16px">燃气设备</h1>
			<li>
				<p>液化气钢瓶</p>
				<div class="yehuaqi"><span>15kg</span><input type="number" name="company[yhqgpfifteen]" value="{{$company->yhqgpfifteen or '' }}" /><span>个，50kg</span><input type="number" value="{{$company->yhqgpfifty or '' }}" name="company[yhqgpfifty]" /><span>个</span></div>

			</li>
			<li><p>天然气管道</p>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[trqgd]" value="1" @if(isset($company) && $company->trqgd == 1) checked @endif>
					<span class="demo--radioInput"></span>是
				</label>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[trqgd]" value="2" @if(isset($company) && $company->trqgd == 2) checked @elseif(!isset($company)) checked @endif>
					<span class="demo--radioInput"></span>否
				</label>
			</li>
			<li>
				<p>醇基燃料</p>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[cjrl]" value="1" @if(isset($company) && $company->cjrl == 1) checked @endif>
					<span class="demo--radioInput"></span>是
				</label>
				<label class="demo--label">
					<input class="demo--radio" type="radio" name="company[cjrl]" value="2" @if(isset($company) && $company->cjrl == 2)checked @elseif(!isset($company)) checked @endif>
					<span class="demo--radioInput"></span>否
				</label>
			</li>
			<input type="hidden" name="safeId" value="{{$safeoffer->id or ''}}">
			<li class="iuyr"><p>门头照片 <span style="color: red;display: block;">(必填项)</span></p><div class="container">


				</div></li>
			@if(isset($company->photo))
				<img class="turew" src="{{$company->photo}}">
			@endif
			<div id="dcontent" class="dcontent">
				<p style="display: none;" class="heading">上传文件列表：</p>
				<ul id="files" style="text-align:left;display: none;">

				</ul>
				<table>
					<tbody>
					<tr class="ha">
						<td><div class="push_button" onclick="appendByCamera()">拍照</div></td>
						<td><div class="push_button" onclick="appendByGallery()">相册</div></td>
						<td><div class="push_button" onclick="upload(this,1)">上 传</div>
						</td>
					</tr>
					<input type="hidden" name="company[photo]" id="img1" value="{{$company->photo or '' }}" />
					<tr class="ha">
					</tr>
					</tbody>
				</table>
			</div>
			<li><p>营业执照 <span style="color: red;display: block;">(必填项)</span></p><div class="container"></div></li>
			@if(isset($company->license))
				<img class="turew" src="{{$company->license}}">
			@endif
			<div id="dcontent" class="dcontent">
				<p style="display: none;" class="heading">上传文件列表：</p>
				<ul id="files" style="text-align:left;display: none;">

				</ul>
				<table>
					<tbody>
					<tr class="ha">
						<td><div class="push_button" onclick="appendByCamera()">拍照</div></td>
						<td><div class="push_button" onclick="appendByGallery()">相册</div></td>
						<td><div class="push_button" onclick="upload(this,2)">上 传</div>
						</td>
					</tr>
					<input type="hidden" name="company[license]" id="img2" value="{{$company->license or '' }}" />
					<tr class="ha">
					</tr>
					</tbody>
				</table>
			</div>

		</ul>


	</div>
	@if($type != 3)
		<input type="submit" class="qrtj dibuann" value="提交">
	@endif
</form>
<script type="text/javascript">
	var server="http://yhpc.ccshe.com/upload/uploadimg";
	var files=[];
	// 上传文件
	function upload(a,b){

		if(files.length<=0){
			plus.nativeUI.alert("没有添加上传文件！");
			return;
		}

		var wt=plus.nativeUI.showWaiting();
		var task=plus.uploader.createUpload(server,
				{method:"POST"},
				function(t,status){ //上传完成
					var rsult=JSON.parse(t.responseText);

					if(status==200){
						var yu='img'+b;
						var td = a.parentNode;
						var tr = td.parentNode;
						var newImg = document.createElement("img");
						//document.getElementByname('img').value += rsult.data + ',';
						document.getElementById(yu).value = rsult.data;
						newImg.src = rsult.data;

						tr.appendChild(newImg);

						wt.close();
					}else{
						outLine("上传失败："+status);
						wt.close();
					}
				}
		);
		task.addData("client","HelloH5+");
		task.addData("uid",getUid());
		for(var i=0;i<files.length;i++){
			var f=files[i];
			task.addFile(f.path,{key:f.name});
		}
		task.start();
		files=[];
	}
	// 拍照添加文件
	function appendByCamera(){
		plus.camera.getCamera().captureImage(function(p){
			appendFile(p);
		});
	}
	// 从相册添加文件
	function appendByGallery(){
		plus.gallery.pick(function(p){
			appendFile(p);
		});
	}
	// 添加文件
	var index=1;
	function appendFile(p){
		var fe=document.getElementById("files");
		var li=document.createElement("li");
		var n=p.substr(p.lastIndexOf('/')+1);
		li.innerText=n;
		fe.appendChild(li);
		files.push({name:"fileImg",path:p});
		index++;
		empty.style.display="none";
	}
	// 产生一个随机数
	function getUid(){
		return Math.floor(Math.random()*100000000+10000000).toString();
	}
</script>
<script type="text/javascript">
	$(".province").change(function(){
		var province = $(this).find('option:selected').val();
		if(province > 0) {
			/*获取数据*/
			getChildren(province, '.city', '.province');
			event.stopPropagation();
		} else {
			/*清除数据*/
			clearNextData(".province");
		}
	});
	$(".city").change(function(){
		var city = $(this).find('option:selected').val();
		if(city > 0) {
			/*获取数据*/
			getChildren(city, '.area', '.city');
		} else {
			/*清除数据*/
			clearNextData(".city");
		}
	});
	$(".area").change(function(){
		var area = $(this).find('option:selected').val();
		if(area > 0) {
			/*获取数据*/
			getChildren(area, '.street', '.area');
		} else {
			/*清除数据*/
			clearNextData(".area");
		}
	});
	function getChildren(parentId,container,parentContainer) {
		/*清除select数据*/
		clearNextData(parentContainer);
		var url = "/area/getarea/"+parentId;
		$.ajax({
			type: "GET",
			url: url,
			data: {},
			dataType: "json",
			success: function(data){
				if(data!==null)
				{
					dataLen = data.length;
					var optionData = '';
					for(var i=0; i<dataLen; i++) {
						$(container).children("option").remove();
						var tmpOption = '<option value="'+data[i].id+'">'+data[i].name+'</option>';
						optionData += tmpOption;
					}
					$(container).append(optionData);
					return true;
				} else {
					alert("请求出错了!");
					return false;
				}
			},
			error: function(){
				alert("请求出错了!");
				return false;
			}
		});
	}

	function clearNextData(container) {
		var nextAllSelect = $(container).nextAll("select");
		var nexAllSelectLen = nextAllSelect.length;
		var first_option = '';
		for(var i=0;i<nexAllSelectLen;i++) {
			first_option = nextAllSelect[i].options[0];
			$(nextAllSelect[i]).find("option").remove();
			$(nextAllSelect[i]).append(first_option);
		}
	}
</script>
<script>
	function del(ob){
		ob.parentNode.parentNode.removeChild(ob.parentNode);
	}
</script>
@include('error.alerts')
</body>
</html>